package com.ruoyi.device.controller;

import java.util.List;
import java.io.IOException;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.device.domain.GraphicsLibraryType;
import com.ruoyi.device.service.IGraphicsLibraryTypeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 图元图形库类型Controller
 * 
 * @author ruoyi
 * @date 2025-09-19
 */
@RestController
@RequestMapping("/graphicsType")
@Tag(name = "图元图形库类型", description = "图元图形库类型相关操作API")
public class GraphicsLibraryTypeController extends BaseController
{
    @Autowired
    private IGraphicsLibraryTypeService graphicsLibraryTypeService;

    /**
     * 查询图元图形库类型列表
     */
    @Operation(summary = "查询图元图形库类型列表", description = "查询图元图形库类型列表")
    @RequiresPermissions("system:graphicsType:list")
    @GetMapping("/list")
    public TableDataInfo list(GraphicsLibraryType graphicsLibraryType)
    {
        startPage();
        List<GraphicsLibraryType> list = graphicsLibraryTypeService.selectGraphicsLibraryTypeList(graphicsLibraryType);
        return getDataTable(list);
    }

    /**
     * 导出图元图形库类型列表
     */
    @Operation(summary = "导出图元图形库类型列表", description = "导出图元图形库类型列表")
    @RequiresPermissions("system:graphicsType:export")
    @Log(title = "图元图形库类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GraphicsLibraryType graphicsLibraryType)
    {
        List<GraphicsLibraryType> list = graphicsLibraryTypeService.selectGraphicsLibraryTypeList(graphicsLibraryType);
        ExcelUtil<GraphicsLibraryType> util = new ExcelUtil<GraphicsLibraryType>(GraphicsLibraryType.class);
        util.exportExcel(response, list, "图元图形库类型数据");
    }

    /**
     * 获取图元图形库类型详细信息
     */
    @Operation(summary = "获取图元图形库类型详细信息", description = "获取图元图形库类型详细信息")
    @RequiresPermissions("system:graphicsType:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(graphicsLibraryTypeService.selectGraphicsLibraryTypeById(id));
    }

    /**
     * 新增图元图形库类型
     */
    @Operation(summary = "新增图元图形库类型", description = "新增图元图形库类型")
    @RequiresPermissions("system:graphicsType:add")
    @Log(title = "图元图形库类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GraphicsLibraryType graphicsLibraryType)
    {
        return toAjax(graphicsLibraryTypeService.insertGraphicsLibraryType(graphicsLibraryType));
    }

    /**
     * 修改图元图形库类型
     */
    @Operation(summary = "修改图元图形库类型", description = "修改图元图形库类型")
    @RequiresPermissions("system:graphicsType:edit")
    @Log(title = "图元图形库类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GraphicsLibraryType graphicsLibraryType)
    {
        return toAjax(graphicsLibraryTypeService.updateGraphicsLibraryType(graphicsLibraryType));
    }

    /**
     * 删除图元图形库类型
     */
    @Operation(summary = "删除图元图形库类型", description = "删除图元图形库类型")
    @RequiresPermissions("system:graphicsType:remove")
    @Log(title = "图元图形库类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(graphicsLibraryTypeService.deleteGraphicsLibraryTypeByIds(ids));
    }
    /**
     * 获取图元图形列表数据给maotu使用
     */
    @Operation(summary = "获取图元图形列表数据给maotu使用", description = "获取图元图形列表数据给maotu使用")
    @RequiresPermissions("system:graphicsType:query")
    @GetMapping(value = "/getMaotu")
    public AjaxResult getMaotu()
    {
        return success(graphicsLibraryTypeService.selectGraphicsLibraryTypeGetMaotu());
    }
}
